package com.maoxx.libms.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.maoxx.libms.controller.dto.RecordDto;
import com.maoxx.libms.entity.User;
import com.maoxx.libms.mapper.UserMapper;
import com.maoxx.libms.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2024-10-25
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {

    @Resource
    private UserMapper userMapper;

    @Override
    @Transactional
    public PageInfo<RecordDto> getAllUsersRecord(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<RecordDto> allUsersRecord = userMapper.getAllUsersRecord();
        return new PageInfo<>(allUsersRecord);
    }

    @Override
    public boolean updateUser(User user) {
        int update = userMapper.updateById(user);
        return update > 0;
    }
}
